import { SideBar } from '@/Layout/components'
import {storageLocal,storageSession} from '@/storage'
import type {Action,Mutation,Commit} from 'vuex'
interface TGAppState{
    sideBar:{
        open:boolean
    }
}
const state = {
       sideBar:{
           open:storageLocal.getItem('sideBarState')? !!+storageLocal.getItem('sideBarState'):true
       }
}
const mutations = {
     TOGGLE_SIDEBAR:(state:TGAppState)=>{
           state.sideBar.open = !state.sideBar.open
           if(state.sideBar.open){
            storageLocal.setItem('sideBarState',1)
           }else{
            storageLocal.setItem('sideBarState',0)
           }
     },
     CLOSE_SIDEBAR:(state:TGAppState)=>{
           state.sideBar.open = false
           storageLocal.setItem('sideBarState',0)
     }
}

const actions = {
     closeSidebar:({commit})=>{
        commit('CLOSE_SIDEBAR') 
     },
     toggleSidebar:({commit})=>{
         commit('TOGGLE_SIDEBAR')
     }
}
export default {
    namespaced:true,
    state,
    mutations,
    actions
}